﻿using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenCVInfras;
public class PaintMatService
{
    public static Mat? PaintMask(Mat? mask, Color maskColor)
    {
        if (mask == null) return null;
        var mat = new Mat(mask.Rows, mask.Cols, MatType.CV_8UC4, new Scalar(0, 0, 0, 0));
        for (var i = 0; i < mask.Rows; i++)
        {
            for (var j = 0; j < mask.Cols; j++)
            {
                if (mask.At<byte>(i, j) <= 0) continue;
                mat.Set<Vec4b>(i, j, new Vec4b(maskColor.B, maskColor.G, maskColor.R, 100));
            }
        }
        return mat;
    }
}
